import 'package:enterprise_v6_app/app/components/custom_app_bar.dart';
import 'package:enterprise_v6_app/app/components/custom_modele/custom_card.dart';
import 'package:enterprise_v6_app/app/components/custom_modele/custom_row_title.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/ext/widget_extension.dart';
import 'package:enterprise_v6_app/app/core/utils/interface.dart';
import 'package:enterprise_v6_app/app/data/entities/application/standing_book/receipt_info_entity.dart';

/// 签字表
class SignatureFormPage extends StatelessWidget {
  const SignatureFormPage({super.key});

  //作业人类型 0：作业实施人 1：作业负责人 2：监护人 3:编制人 4：司索人 5:指挥人 6：用电人 7：安全交底人 8：接受交底人 9：验收人
  String _type(int? i) {
    switch (i) {
      case 0:
        return '作业实施人';
      case 1:
        return '作业负责人';
      case 2:
        return '监护人';
      case 3:
        return '编制人';
      case 4:
        return '司索人';
      case 5:
        return '指挥人';
      case 6:
        return '用电人';
      default:
        return '';
    }
  }

  @override
  Widget build(BuildContext context) {
    final ReceiptInfoEntity receiptInfoEntity = Get.arguments as ReceiptInfoEntity;
    return Scaffold(
      backgroundColor: AppColors.bg_color_grey,
      appBar: CustomAppBar(
        titleText: '签字表',
      ),
      body: Container(
        padding: EdgeInsets.all(16.w),
        child: CustomCard(
          title: '签字确认表',
          content: Container(
            padding: EdgeInsets.all(8.w),
            decoration: BoxDecoration(
              color: const Color(0xFFF7F7FB),
              borderRadius: BorderRadius.circular(6.w),
              border: Border.all(
                color: const Color(0xFFEBEDF0),
                width: 1.w,
              ),
            ),
            child: Column(
              children: receiptInfoEntity.receiptInfo!.operatorLists!.map((e) {
                if(e.operatorUserSign!.isEmpty){
                  return Container();
                }
                return CustomRowTitle(
                  title: _type(e.operatorType),
                  contentWidget: Row(
                    mainAxisAlignment: MainAxisAlignment.end,
                    children: [
                      Text(
                        '${e.operatorUserName}',
                        style: TextStyle(
                          fontSize: 12.sp,
                          color: AppColors.font_color_black,
                        ),
                      ),
                      AppGaps.hGap8,
                      Image.network(height: 30.w, Interface.fileUrl + e.operatorUserSign.toString())
                          .clickShowLarge(url: Interface.fileUrl + e.operatorUserSign.toString()),
                    ],
                  ),
                );
              }).toList(),
            ),
          ),
        ),
      ),
    );
  }
}
